package com.ht.api.gaoxian;


import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.domain.AnttechNftTransferApplyModel;
import com.alipay.api.request.AnttechNftTransferApplyRequest;
import com.alipay.api.response.AnttechNftTransferApplyResponse;

import com.alipay.api.FileItem;
import java.util.Base64;
import java.util.ArrayList;
import java.util.List;

public class AnttechNftTransferApply {

    public static void main(String[] args) throws AlipayApiException {
        // 初始化SDK
        AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());

        // 构造请求参数以调用接口
        AnttechNftTransferApplyRequest request = new AnttechNftTransferApplyRequest();
        AnttechNftTransferApplyModel model = new AnttechNftTransferApplyModel();

        // 设置请求消息id
        model.setReqMsgId("b20167e21a8d4cc2b5f1022d24f4***");

        // 设置藏品标识sku
        model.setSkuId(10L);

        // 设置被转入用户的支付宝uid或手机号
        model.setIdNo("1000");

        // 设置支付宝openid
        model.setOpenId("074a1CcTG1LelxKe4xQC0zgNdId0nxi95b5lsNpazWYoCo5");

        // 设置用户标识类型
        model.setIdType("ALIPAY_UID");

        // 设置用户购买价格
        model.setPriceCent(1800L);

        // 设置用户在商户购买的订单号
        model.setOrderNo("201322****");

        // 设置调用方渠道租户
        model.setChannelTenant("ULKTIGAW");

        request.setBizModel(model);
        // 第三方代调用模式下请设置app_auth_token
        // request.putOtherTextParam("app_auth_token", "<-- 请填写应用授权令牌 -->");

        AnttechNftTransferApplyResponse response = alipayClient.execute(request);
        System.out.println(response.getBody());

        if (response.isSuccess()) {
            System.out.println("调用成功");
        } else {
            System.out.println("调用失败");
            // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接
            // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response);
            // System.out.println(diagnosisUrl);
        }
    }

    private static AlipayConfig getAlipayConfig() {
        String privateKey  = "<-- 请填写您的应用私钥，例如：MIIEvQIBADANB ... ... -->";
        String alipayPublicKey = "<-- 请填写您的支付宝公钥，例如：MIIBIjANBg... -->";
        AlipayConfig alipayConfig = new AlipayConfig();
        alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
        alipayConfig.setAppId("<-- 请填写您的AppId，例如：2019091767145019 -->");
        alipayConfig.setPrivateKey(privateKey);
        alipayConfig.setFormat("json");
        alipayConfig.setAlipayPublicKey(alipayPublicKey);
        alipayConfig.setCharset("UTF-8");
        alipayConfig.setSignType("RSA2");
        return alipayConfig;
    }
}